From: Dale Wijnand Date: Tue, 10 Apr 2018 07:16:57 +0000 (+0100) Subject: found a way to reuse SourceId::for_path in SourceId::from_cwd X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~1^2~81^2~5 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=8bb6827483a645d5d2f978181c2d620553111249;p=cargo.git found a way to reuse SourceId::for_path in SourceId::from_cwd --- diff --git a/src/cargo/core/source/source_id.rs b/src/cargo/core/source/source_id.rs index 7bf6e63fc..784107c21 100644 --- a/src/cargo/core/source/source_id.rs +++ b/src/cargo/core/source/source_id.rs @@ -171,15 +171,13 @@ impl SourceId { /// /// Pass absolute path pub fn from_cwd(path: &Path) -> CargoResult { - let url = path.to_url()?; + let source_id = SourceId::for_path(path)?; + let source_id = Arc::try_unwrap(source_id.inner) + .map_err(|_| format_err!("failed to create SourceId from cwd `{}`", path.display()))?; Ok(SourceId { inner: Arc::new(SourceIdInner { - kind: Kind::Path, - canonical_url: git::canonicalize_url(&url)?, - url, - precise: None, - name: None, from_cwd: true, + ..source_id }), }) }